<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>宣传任务</title>
		<!-- 导入jquery核心类库 -->
		<script type="text/javascript" src="../../js/jquery-1.8.3.js"></script>
		<!-- 导入easyui类库 -->
		<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../js/easyui/ext/portal.css">
		<link rel="stylesheet" type="text/css" href="../../css/default.css">
		<script type="text/javascript" src="../../js/easyui/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../js/easyui/ext/jquery.portal.js"></script>
		<script type="text/javascript" src="../../js/easyui/ext/jquery.cookie.js"></script>
		<script src="../../js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
		<script type="text/javascript">
			$(function() {
				// 宣传任务表格			
				$("#grid").datagrid({
					url : "../../promotion_pageQuery.action",
					columns: [
						[{
							field: 'id',
							title: '编号',
							width: 100,
							checkbox: true
						}, {
							field: 'title',
							title: '宣传概要（标题）',
							width: 200
						}, {
							field: 'titleImg',
							title: '宣传图片',
							width: 200,
							formatter : function(value,row,index){
								return "<img src='"+value+"' width='100' height='100' />";
//								return "<img src='/bos_management/upload/1c506c8b-2c6a-4de8-9fba-271bd0841c40.jpg' width='100' height='100' />";
							}
						},{
							field: 'startDate',
							title: '发布时间',
							width: 100,
							formatter : function(value,row,index){
								return value.replace("T"," ");
							}
						}, {
							field: 'endDate',
							title: '实效时间',
							width: 100,
							formatter : function(value,row,index){
								return value.replace("T"," ");
							}
						}, {
							field: 'updateTime',
							title: '更新时间',
							width: 100
						}, {
							field: 'updateUnit',
							title: '更新单位',
							width: 100
						}, {
							field: 'updateUser',
							title: '更新人',
							width: 100
						}, {
							field: 'status',
							title: '状态',
							width: 100
						}]
					],
					pagination: true,
					toolbar: [{
							id: 'searchBtn',
							text: '查询',
							iconCls: 'icon-search'
						}, {
							id: 'addBtn',
							text: '增加',
							iconCls: 'icon-add',
							handler: function() {
								location.href = "promotion_add.html";
							}
						}, {
							id: 'editBtn',
							text: '修改',
							iconCls: 'icon-edit',
							handler: doEdit
						}, {
							id: 'deleteBtn',
							text: '作废',
							iconCls: 'icon-cancel',
							handler: function() {
								alert('作废');
							}
						},{
							id: 'saveBtn',
							text: '保存',
							iconCls: 'icon-save',
							handler: function() {
								alert('保存成功');
							}
						},
						{
							id: 'cancelBtn',
							text: '取消',
							iconCls: 'icon-no',
							handler: function() {
								alert('取消宣传任务');
							}
						}

					]
				});

				function doEdit() {
					// 获取当前datagrid选中数据 
					var rows = $("#grid").datagrid('getSelections');
					if(rows.length != 1){
						// 没选 或 多选 
						$.messager.alert("提示信息","修改数据时，只能选中一行","warning");
					}else{
						// 只选中一行 
						var row=rows[0];
						//将json数据转换为字符串
						var	promotion=JSON.stringify(row);
						//将数据存储到html5的localStorage中
						localStorage.setItem("promotion",promotion);
						location.href = "promotion_edit.html";
					}
				}
				
			});
		</script>
	</head>

	<body class="easyui-layout">
		<div region="center" style="overflow:auto;padding:5px;">
			<table id="grid"></table>
		</div>
		
		
		
		<div class="easyui-window" title="对宣传任务进行添加或者修改" id="promotionWindow" 
			collapsible="false" minimizable="false" maximizable="false" style="top:20px;left:200px" closed="true" model="true">
			<div region="center" style="overflow:auto;padding:5px;" border="false">
				<form id="promotionForm" enctype="multipart/form-data"
					action="../../promotion_save.action" method="post">
					<table class="table-edit" width="100%" align="center">
						<tr class="title">
							<td colspan="4">宣传任务</td>
						</tr>
						<tr>
							<td>宣传概要(标题):</td>
							<td colspan="3">
								<input type="text" name="title" id="title" class="easyui-validatebox" required="true" />
							</td>
						</tr>
						<tr>
							<td>活动范围:</td>
							<td>
								<input type="text" name="activeScope" id="activeScope" class="easyui-validatebox" />
							</td>
							<td>宣传图片:</td>
							<td>
								<input type="file" name="titleImgFile" value="hello" id="titleImg" class="easyui-validatebox" required="true"/>
								<div id="showImgDiv" style="width:100%;height:100%;overflow:hidden;">
								</div>
							</td>
						</tr>
						<tr>
							<td>发布时间: </td>
							<td>
								<input type="text" name="startDate" id="startDate" class="easyui-datebox" required="true" />
							</td>
							<td>失效时间: </td>
							<td>
								<input type="text" name="endDate" id="endDate" class="easyui-datebox" required="true" />
							</td>
						</tr>
						<tr>
							<td>宣传内容(活动描述信息):</td>
							<td colspan="3">
								<textarea id="description" name="description" style="width:80%" rows="20"></textarea>
							</td>
						</tr>
					</table>
				</form>
			</div>
		</div>
		
	</body>
</html>